<?php get_header(); ?>
<div id="img_show">
	<div id="postlist">
		<div class="post-arc">
			<div class="posttitle-arc">
				<h2>照片墙</h2>
				<h2><?php $tax=get_terms("img_taxonomy");
					foreach ($tax as $term) {
						//echo $term->name;
						echo '<a href="'.get_term_link($term).'">'.$term->name.'</a>';
						echo "  ";
					}
				?></h2>
			</div>
			<div class="clear"></div>
					<?php query_posts($query_string."&post_type'=imgshow&showposts=10&orderby=comment_count"); ?>
					<?php if(have_posts()) : while (have_posts()) : the_post(); ?>
					<div class="photo">
					<div class="abs">
							<img src="<?php $img=get_post_custom_values("img_url");echo $img[0];?>"></img>
							
								<div class="photo_back" style="display:none">
									<a href="<?php the_permalink() ?>">
									<h1><?php the_title(); ?></h1>
									<hr/>
									<h3><?php the_excerpt(); ?></h4>
									<br/>
									<h5>
										<?php _e('view','may701');?><?php echo getPostViews(get_the_ID());?><?php _e('numbers','may701')?>
									</h5>
									<h4>
										<?php _e('comment','may701');?><?php $a=get_comment_count(get_the_ID()); echo $a['approved'];?><?php _e('numbers','may701')?>
									</h4>			
									</a>	
								</div>

						</div>
					</div>				
					<?php endwhile; endif; ?>
		</div>
		<!--<div class="pagenavi"><?php pagenavi(); ?></div>	-->
	</div>
</div>
<?php get_footer(); ?>
<script type="text/javascript">
	function img_init()
		{
			$("img").transition({opacity:1},"2000")
			$("#img_show img").live("mouseenter",function(){
				$(this).transition({rotateY:"180deg", delay:200})
				{
					$(this).next().css("display","block")
					$(this).next().transition({opacity:1},"slow")
				}
			})
			$(".photo_back").live("mouseleave","slow",function(){
				$(this).transition({opacity:0},function(){
					$(this).prev().transition({rotateY:"0deg", delay:100})
					$(this).css("display","none")
				})
			})
		}
	$(document).ready(function(){
		<?php global $wp_query;
		$max_page = $wp_query->max_num_pages;?>
		var max_page=<?php echo $max_page;?>;
		var page=1
		img_init()
		$(window).bind("scroll",function(){
		if( $(document).scrollTop() + $(window).height() > $(document).height() - 20 ){
				if(page<max_page)
				{
					$.ajax({
					  url: "<?php echo get_bloginfo("url")?>",
					  data: {cat:"10",paged:++page},
					  success: function(result){
					  	$(result).find("div .photo").each(function(){                        
                        	$(".post-arc").append("<div class='photo'>"+$(this).html()+"</div>")
                        	$(".post-arc img").last().transition({opacity:1},"2000")
                    	});
					  },
					});
				}
			}
		})
	})
</script>